package com.cowin.inf.controller;

import com.cowin.base.result.Result;
import com.cowin.base.result.ResultGenerator;
import com.cowin.base.BaseController;
import com.cowin.inf.model.KyDeviceState;
import com.cowin.inf.model.KyLineState;
import com.cowin.inf.model.vo.LineStateVo;
import com.cowin.inf.service.KyDeviceStateService;
import com.cowin.inf.service.KyLineStateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by  on 2019/09/19.
 *
 * @author CodeGenerator
 */
@Slf4j
@Api(value = "KyLineStateController", description = "产线状态控制器", tags = "KyLineStateController", consumes = "application/json")
@RestController
@RequestMapping("/ky/line/state")
public class KyLineStateController extends BaseController<KyLineState> {
    @Resource
    private KyLineStateService kyLineStateService;
    @Resource
    private KyDeviceStateService kyDeviceStateService;

    @ApiOperation(value = "产线监控初始化", notes = "产线监控初始化")
    @GetMapping("/init/{plantNo}/{workShopNo}")
    public Result initLineState(@PathVariable String plantNo, @PathVariable String workShopNo) {
        return ResultGenerator.genSuccessResult(kyLineStateService.initLineState(plantNo, workShopNo));
    }

    @ApiOperation(value = "产线监控初始化", notes = "产线监控初始化")
    @PostMapping("/monitor")
    public Result lineStateMonitor(@RequestBody KyDeviceState kyDeviceState) {
        log.info("产线状态=={}" ,kyDeviceState.toString());
        kyDeviceStateService.save(kyDeviceState);
        return ResultGenerator.genSuccessResult();
    }
}
